package com.sudoku.SudokuV01;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;


public class MyActivity extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button b1= (Button) findViewById (R.id.button1);
        Button b2= (Button) findViewById (R.id.button2);
        Button b3= (Button) findViewById (R.id.buttonbd);
        final Activity leContext = this;
       b1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent defineIntent = new Intent(leContext, level1List.class);
                defineIntent.putExtra("level",1.0);
                leContext.startActivity(defineIntent);

            }
        });

        b2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent defineIntent = new Intent(leContext, level1List.class);
                defineIntent.putExtra("level",2.0);
                leContext.startActivity(defineIntent);

            }
        });
        b3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                // On va lancer l'activité pour la bdd

                Log.w(" BDD \n\n","ouverture base de donnée ");
                Log.w(" BDD \n\n", "Lecture fichier source ");
                int fileResourceId = R.raw.fichier0;
                InputStream is = getResources()
                        .openRawResource(fileResourceId);
                BufferedReader reader = new BufferedReader(
                        new InputStreamReader(is));
                String str="";
                String buf="";

                if (is!=null) {
                    try {
                        while ((str = reader.readLine()) != null) {
                           // buf+=(str + "\n" );
                            Log.w(" BDD \n\n", str);
                        }

                        is.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }


            }
        });


    }


}
